<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>Title</title>
    <link rel="stylesheet" href="../static/plugins/layui/css/layui.css">
</head>
<style>
    .ok-body {
        padding: 10px
    }
</style>

<body>
<div class="ok-body">

    <blockquote id="title" class="layui-elem-quote layui-text">

    </blockquote>

    <form class="layui-form" >
        <div class="layui-form-item">
            <input type="hidden" name="id" id="id"  th:value="${id}" >
            <input type="hidden" id="type"  th:value="${type}" >

            <div class="layui-form-item" >
                <label class="layui-form-label">执行结果</label>
                <div class="layui-input-block" style="width: 300px">
                    <textarea id="result" readonly lay-verify="required"  class="layui-textarea"></textarea>
                </div>
            </div>

        </div>

        <div class="layui-form-item">
            <div class="layui-form-item" >
                <label class="layui-form-label">执行评价</label>
                <div class="layui-input-block" style="width: 300px">
                    <textarea name="comment"  placeholder="请对该次检查进行评价"  class="layui-textarea"></textarea>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">结果</label>
            <div class="layui-input-inline">
                <input type="checkbox" checked="" name="status" lay-skin="switch" value="1" lay-text="通过|驳回">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" style="margin-left: 80px;" lay-submit="" lay-filter="submit">确认</button>
            </div>
        </div>

    </form>

</div>

<script src="../static/plugins/layui/layui.js"></script>
<script src="../static/js/jquery-3.2.1.min.js"></script>
<script src="../static/js/jquery.base64.js"></script>
<script src="../static/js/device.js"></script>

<script th:inline="none">
    layui.use(['form'], function(){
        var form = layui.form;
        var id = $('#id').val();

        var type = $('#type').val();

        JJZ.requestData('/inspectionTask/getInspectionTask','id='+id,function(data){
            $('#result').val(data.result);
            if(type == 1){
                $('#title').text('班长评价');
            }else if(type == 2){
                $('#title').text('主管评价');
            }
        });
        form.on('submit(submit)', function(data){
            var status;
            if(type == 1){
                //    班长确认
                status = data.field.status == 1 ? 3 : 5;
            }else{
                //    主管确认
                status = data.field.status == 1 ? 4 : 5;
            }
            var param = 'id='+data.field.id+'&comment='+data.field.comment+'&type='+type+'&status='+status;
            JJZ.requestData('/inspectionTask/addComment',param,function (dataInfo) {
                window.location.href = JJZ.baseUrl+'/inspectionTask/inspectionTaskDataGrid';
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

    });
</script>
</body>
</html>